#include<bits/stdc++.h>
using namespace std;
int main() {
	int n, cnt = 0;
	cin >> n;
	while (cin >> n) {
		if (n)
			cout << n << " ";
		else
			cnt++;
	}
	while (cnt--) {
		cout << "0 ";
	}
	return 0;
}
